from django.db import models

from blog.models import Article

from datetime import datetime

# Create your models here.


class Comment(models.Model):
    name = models.CharField(max_length=30, verbose_name='用户名')
    email = models.CharField(max_length=50, verbose_name='邮箱')
    url = models.URLField(max_length=50, null=True, verbose_name='网站')
    comment = models.CharField(max_length=500, verbose_name='留言')
    article = models.ForeignKey(Article, verbose_name='文章')
    add_time = models.DateTimeField(default=datetime.now, verbose_name='添加时间')

    class Meta:
        ordering = ['-add_time']
        verbose_name = '留言'
        verbose_name_plural = verbose_name

    def __str__(self):
        return '{}({})'.format(self.name, self.comment)



